package com.ke.controller;


import com.ke.pojo.BaseResp;
import com.ke.service.ArticleCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/articleCart")
@CrossOrigin(allowCredentials = "true")
public class ArticleCartController {

    @Autowired
    ArticleCartService articleCartService;


    /**
     * 添加到文章购物车
     * @param map
     * @param request
     * @return
     */
    @RequestMapping("/addArticleCart")
    public BaseResp addArticleCart(@RequestBody Map map , HttpServletRequest request){

        return articleCartService.addArticleCart(Integer.valueOf(map.get("id").toString()),request);
    }

    @RequestMapping("/findAllArticleCart")
    public BaseResp findAllArticleCart(HttpServletRequest request){
        return articleCartService.findAllArticleCart(request);
    }
    @RequestMapping("/deleteArticleCart")
    public BaseResp deleteArticleCart(@RequestBody Map map , HttpServletRequest request){
        return articleCartService.deleteArticleCart(Integer.valueOf(map.get("id").toString()),request);
    }
}
